import crafttweaker.api.events.CTEventManager;
import crafttweaker.api.util.text.MCTextComponent;
import crafttweaker.api.event.entity.player.MCPlayerLoggedInEvent;
import crafttweaker.api.server.MCServer;
import crafttweaker.api.world.MCServerWorld;
import mods.gamestages.events.GameStageAdded;

//玩家进入游戏
CTEventManager.register<MCPlayerLoggedInEvent>(event => {
	val player = event.player;
	val playerName = player.name;

	if(playerName != "gu__meng"){
		player.sendMessage(MCTextComponent.createStringTextComponent(playerName + "加入游戏"));
		if(!player.hasGameStage("creative")){
			if(player.isCreative()){
				player.sendMessage(MCTextComponent.createStringTextComponent(playerName + "玩家有作弊嫌疑"));
				player.sendMessage(MCTextComponent.createStringTextComponent("正在清除" + playerName + "作弊操作"));
				player.getWorld().asServerWorld().server.executeCommand("gamemode survival " + playerName,true);
				player.sendMessage(MCTextComponent.createStringTextComponent("成功清除" + playerName + "的作弊操作"));
			}
		}
	}else{
		player.sendMessage(MCTextComponent.createStringTextComponent(playerName + "顺利进入游戏"));
	}
});
//当玩家解锁了某个阶段
CTEventManager.register<GameStageAdded>(event => {
	if(event.stage == "start"){
		event.player.sendMessage(MCTextComponent.createStringTextComponent("恭喜玩家 " + event.player.name + " 解锁阶段：正式开始游戏"));
	}
});